package br.com.mucceli.politicapopular.model;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author mucceli
 */
@Entity
@Table(name = "POLITICO")
@NamedQueries({
    @NamedQuery(name = "Politico.findAll", query = "SELECT p FROM Politico p"),
    @NamedQuery(name = "Politico.findByIdPolitico", query = "SELECT p FROM Politico p WHERE p.idPolitico = :idPolitico"),
    @NamedQuery(name = "Politico.findByFkCidade", query = "SELECT p FROM Politico p WHERE p.fkCidade = :fkCidade"),
    @NamedQuery(name = "Politico.findByFkPartido", query = "SELECT p FROM Politico p WHERE p.fkPartido = :fkPartido"),
    @NamedQuery(name = "Politico.findByFkHistorico", query = "SELECT p FROM Politico p WHERE p.fkHistorico = :fkHistorico")})
public class Politico implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_POLITICO")
    private Integer idPolitico;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "NOME")
    private String nome;
    @Lob
    @Column(name = "FOTO")
    private byte[] foto;
    @Lob
    @Size(max = 65535)
    @Column(name = "TELEFONE")
    private String telefone;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Lob
    @Size(max = 65535)
    @Column(name = "EMAIL")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FK_CIDADE")
    private int fkCidade;
    @Basic(optional = false)
    @NotNull
    @Column(name = "FK_PARTIDO")
    private int fkPartido;
    @Column(name = "FK_HISTORICO")
    private Integer fkHistorico;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkPolitico")
    private Collection<Eleicao> eleicaoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "politico")
    private Collection<PoliticoEscandalo> politicoEscandaloCollection;

    public Politico() {
    }

    public Politico(Integer idPolitico) {
        this.idPolitico = idPolitico;
    }

    public Politico(Integer idPolitico, String nome, int fkCidade, int fkPartido) {
        this.idPolitico = idPolitico;
        this.nome = nome;
        this.fkCidade = fkCidade;
        this.fkPartido = fkPartido;
    }

    public Integer getIdPolitico() {
        return idPolitico;
    }

    public void setIdPolitico(Integer idPolitico) {
        this.idPolitico = idPolitico;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public byte[] getFoto() {
        return foto;
    }

    public void setFoto(byte[] foto) {
        this.foto = foto;
    }

    public String getTelefone() {
        return telefone;
    }

    public void setTelefone(String telefone) {
        this.telefone = telefone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getFkCidade() {
        return fkCidade;
    }

    public void setFkCidade(int fkCidade) {
        this.fkCidade = fkCidade;
    }

    public int getFkPartido() {
        return fkPartido;
    }

    public void setFkPartido(int fkPartido) {
        this.fkPartido = fkPartido;
    }

    public Integer getFkHistorico() {
        return fkHistorico;
    }

    public void setFkHistorico(Integer fkHistorico) {
        this.fkHistorico = fkHistorico;
    }

    public Collection<Eleicao> getEleicaoCollection() {
        return eleicaoCollection;
    }

    public void setEleicaoCollection(Collection<Eleicao> eleicaoCollection) {
        this.eleicaoCollection = eleicaoCollection;
    }

    public Collection<PoliticoEscandalo> getPoliticoEscandaloCollection() {
        return politicoEscandaloCollection;
    }

    public void setPoliticoEscandaloCollection(Collection<PoliticoEscandalo> politicoEscandaloCollection) {
        this.politicoEscandaloCollection = politicoEscandaloCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPolitico != null ? idPolitico.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Politico)) {
            return false;
        }
        Politico other = (Politico) object;
        if ((this.idPolitico == null && other.idPolitico != null) || (this.idPolitico != null && !this.idPolitico.equals(other.idPolitico))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mycompany.mavenproject1.Politico[ idPolitico=" + idPolitico + " ]";
    }
    
}
